home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 January / january_2001.iso / intercd / root / ^4Developers / VB / visbasdb / VBDB / VBDB Code / VB6 Code / Class 6 / Example6-5DE.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-17  |  6.5 KB  |  228 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAuthors 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Authors"
  5.    ClientHeight    =   2625
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4680
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   2625
  13.    ScaleWidth      =   4680
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.CommandButton cmdDone 
  16.       Caption         =   "Do&ne"
  17.       Height          =   375
  18.       Left            =   3240
  19.       TabIndex        =   13
  20.       TabStop         =   0   'False
  21.       Top             =   2160
  22.       Width           =   1215
  23.    End
  24.    Begin VB.CommandButton cmdDelete 
  25.       Caption         =   "&Delete"
  26.       Height          =   375
  27.       Left            =   1680
  28.       TabIndex        =   12
  29.       TabStop         =   0   'False
  30.       Top             =   2160
  31.       Width           =   1215
  32.    End
  33.    Begin VB.CommandButton cmdEdit 
  34.       Caption         =   "&Edit"
  35.       Height          =   375
  36.       Left            =   120
  37.       TabIndex        =   11
  38.       TabStop         =   0   'False
  39.       Top             =   2160
  40.       Width           =   1215
  41.    End
  42.    Begin VB.CommandButton cmdCancel 
  43.       Caption         =   "&Cancel"
  44.       Height          =   375
  45.       Left            =   3240
  46.       TabIndex        =   10
  47.       TabStop         =   0   'False
  48.       Top             =   1680
  49.       Width           =   1215
  50.    End
  51.    Begin VB.CommandButton cmdSave 
  52.       Caption         =   "&Save"
  53.       Height          =   375
  54.       Left            =   1680
  55.       TabIndex        =   9
  56.       TabStop         =   0   'False
  57.       Top             =   1680
  58.       Width           =   1215
  59.    End
  60.    Begin VB.CommandButton cmdAddNew 
  61.       Caption         =   "&Add New"
  62.       Height          =   375
  63.       Left            =   120
  64.       TabIndex        =   8
  65.       TabStop         =   0   'False
  66.       Top             =   1680
  67.       Width           =   1215
  68.    End
  69.    Begin VB.CommandButton cmdNext 
  70.       Caption         =   "Next =>"
  71.       Height          =   255
  72.       Left            =   2520
  73.       TabIndex        =   7
  74.       TabStop         =   0   'False
  75.       Top             =   1320
  76.       Width           =   1215
  77.    End
  78.    Begin VB.CommandButton cmdPrevious 
  79.       Caption         =   "<= Previous"
  80.       Height          =   255
  81.       Left            =   1080
  82.       TabIndex        =   6
  83.       TabStop         =   0   'False
  84.       Top             =   1320
  85.       Width           =   1215
  86.    End
  87.    Begin VB.TextBox txtYearBorn 
  88.       DataField       =   "Year Born"
  89.       DataMember      =   "comAuthors"
  90.       DataSource      =   "denBooks"
  91.       Height          =   285
  92.       Left            =   1200
  93.       Locked          =   -1  'True
  94.       TabIndex        =   2
  95.       Text            =   "Text3"
  96.       Top             =   840
  97.       Width           =   1215
  98.    End
  99.    Begin VB.TextBox txtAuthor 
  100.       DataField       =   "Author"
  101.       DataMember      =   "comAuthors"
  102.       DataSource      =   "denBooks"
  103.       Height          =   285
  104.       Left            =   1200
  105.       Locked          =   -1  'True
  106.       TabIndex        =   1
  107.       Text            =   "Text2"
  108.       Top             =   480
  109.       Width           =   3375
  110.    End
  111.    Begin VB.TextBox txtAuthorID 
  112.       DataField       =   "Au_ID"
  113.       DataMember      =   "comAuthors"
  114.       DataSource      =   "denBooks"
  115.       Height          =   285
  116.       Left            =   1200
  117.       Locked          =   -1  'True
  118.       TabIndex        =   3
  119.       TabStop         =   0   'False
  120.       Text            =   "Text1"
  121.       Top             =   120
  122.       Width           =   1215
  123.    End
  124.    Begin VB.Label Label3 
  125.       Caption         =   "Year Born"
  126.       Height          =   255
  127.       Left            =   120
  128.       TabIndex        =   5
  129.       Top             =   840
  130.       Width           =   1215
  131.    End
  132.    Begin VB.Label Label2 
  133.       Caption         =   "Author Name"
  134.       Height          =   255
  135.       Left            =   120
  136.       TabIndex        =   4
  137.       Top             =   480
  138.       Width           =   1215
  139.    End
  140.    Begin VB.Label Label1 
  141.       Caption         =   "Author ID"
  142.       Height          =   255
  143.       Left            =   120
  144.       TabIndex        =   0
  145.       Top             =   120
  146.       Width           =   1215
  147.    End
  148. Attribute VB_Name = "frmAuthors"
  149. Attribute VB_GlobalNameSpace = False
  150. Attribute VB_Creatable = False
  151. Attribute VB_PredeclaredId = True
  152. Attribute VB_Exposed = False
  153. Option Explicit
  154. Private Sub cmdAddNew_Click()
  155. Call SetState("Add")
  156. End Sub
  157. Private Sub cmdCancel_Click()
  158. Call SetState("View")
  159. End Sub
  160. Private Sub cmdDelete_Click()
  161. Dim Response As Integer
  162. Response = MsgBox("Are you sure you want to delete this record?", vbYesNo + vbQuestion + vbDefaultButton2, "Delete")
  163. If Response = vbNo Then
  164.   Exit Sub
  165. End If
  166. End Sub
  167. Private Sub cmdEdit_Click()
  168. Call SetState("Edit")
  169. End Sub
  170. Private Sub cmdNext_Click()
  171. denBooks.rscomAuthors.MoveNext
  172. If denBooks.rscomAuthors.EOF Then
  173.   Beep
  174.   denBooks.rscomAuthors.MoveLast
  175. End If
  176. End Sub
  177. Private Sub cmdPrevious_Click()
  178. denBooks.rscomAuthors.MovePrevious
  179. If denBooks.rscomAuthors.BOF Then
  180.   Beep
  181.   denBooks.rscomAuthors.MoveFirst
  182. End If
  183. End Sub
  184. Private Sub cmdSave_Click()
  185. MsgBox "Record saved.", vbOKOnly + vbInformation, "Save"
  186. Call SetState("View")
  187. End Sub
  188. Private Sub SetState(AppState As String)
  189. Select Case AppState
  190. Case "View"
  191.   txtAuthorID.BackColor = vbWhite
  192.   txtAuthor.Locked = True
  193.   txtYearBorn.Locked = True
  194.   cmdPrevious.Enabled = True
  195.   cmdNext.Enabled = True
  196.   cmdAddNew.Enabled = True
  197.   cmdSave.Enabled = False
  198.   cmdCancel.Enabled = False
  199.   cmdEdit.Enabled = True
  200.   cmdDelete.Enabled = True
  201.   cmdDone.Enabled = True
  202.   txtAuthor.SetFocus
  203. Case "Add", "Edit"
  204.   txtAuthorID.BackColor = vbRed
  205.   txtAuthor.Locked = False
  206.   txtYearBorn.Locked = False
  207.   cmdPrevious.Enabled = False
  208.   cmdNext.Enabled = False
  209.   cmdAddNew.Enabled = False
  210.   cmdSave.Enabled = True
  211.   cmdCancel.Enabled = True
  212.   cmdEdit.Enabled = False
  213.   cmdDelete.Enabled = False
  214.   cmdDone.Enabled = False
  215.   txtAuthor.SetFocus
  216. End Select
  217. End Sub
  218. Private Sub Form_Activate()
  219. Call SetState("View")
  220. End Sub
  221. Private Sub txtYearBorn_KeyPress(KeyAscii As Integer)
  222. If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or KeyAscii = vbKeyBack Then
  223.   Exit Sub
  224.   Beep
  225.   KeyAscii = 0
  226. End If
  227. End Sub
  228.